package persistence;

public class LibraryLocation {
	private int id;
	private City city;
	
	protected LibraryLocation() {}
	
	protected LibraryLocation(int id, City city) {
		setId(id);
		setCity(city);
	}	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		result = prime * result
				+ ((city == null) ? 0 : city.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		LibraryLocation other = (LibraryLocation) obj;
		if (id != other.id)
			return false;
		if (city == null) {
			if (other.city != null)
				return false;
		} else if (!city.equals(other.city))
			return false;
		return true;
	}
	
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("LibraryLocation: id=").append(id).append(", city=").append(city);
		
		return builder.toString();
	}

	public int getId() {
		return id;
	}

	public City getCity() {
		return city;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setCity(City city) {
		this.city = city;
	}
}
